import React from 'react'
import { connect } from 'react-redux'
import {Tabs,} from 'antd';
const TabPane = Tabs.TabPane;
import CompanyTab from 'containers/enterprise-manage/company-maintain/company-maintain';
import CompanyGroup from 'containers/setting/company-group/company-group';

class CityGroupInfo extends React.Component{
  constructor(props){
    super(props);
    this.state = {
    };
  }

  render () {
    const {currentPageRoute, authPolicyAll, menuPermission}= this.props;
    let disabled = !(authPolicyAll || (menuPermission.authPolicyCompDTO && menuPermission.authPolicyCompDTO.setOfBooksIds.length));
    const {subFunctions}= currentPageRoute;
    return (
      <div className="full-height-page full-page-margin">
        <Tabs>
          {
            subFunctions.map(item => {
              const key = item.key;
              return (
                item.operationType !== 'H' &&
                <TabPane tab={item.resourceName} key={key}>
                  {
                    key === 'company-tab' &&
                    <CompanyTab disabled={item.operationType === 'R'}/>
                  }
                  {
                    key === 'company-group' &&
                    <CompanyGroup disabled={item.operationType === 'R' || disabled}/>
                  }
                </TabPane>
              )
            })
          }
        </Tabs>
      </div>
    )

  }


}
CityGroupInfo.contextTypes = {
  router: React.PropTypes.object,
};
function mapStateToProps(state) {
  return {
    currentPageRoute: state.main.currentPageRoute,
    authPolicyAll: state.main.authPolicyAll,
    menuPermission: state.main.menuPermission,
  }
}

export default connect(mapStateToProps)(CityGroupInfo);
